/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package GUI.NVGH;

import DAO.CTPXuatKhoDao;
import DAO.NhanVienDao;
import DAO.SanPhamDao;
import GUI.Var;
import POJO.NhanVien;
import POJO.SanPham;
import POJO.SanPhamBanTrongNgay;
//import POJO.SanPhamBanTrongNgay;
import java.util.ArrayList;
import javax.swing.DefaultComboBoxModel;
import javax.swing.table.DefaultTableModel;
import javax.xml.bind.ParseConversionEvent;


/**
 *
 * @author Huê
 */
public class frLapBaoCaoXuatKho extends javax.swing.JInternalFrame {

	/**
	 * Creates new form frLapBaoCaoXuatKho
	 */
	public frLapBaoCaoXuatKho() {
		initComponents();
                jlbTenNhanVien.setText(Var.NV.getTenNV());
	}
        private void loadSanPhamDaXuat(int mnv){
            int stt=1;
            ArrayList<SanPhamBanTrongNgay> dsSanPham =CTPXuatKhoDao.layDanhSachSanPhamDaXuat(mnv); 
            String[] columns = new String [] { "STT","Sản phẩm","Số lượng"};
            DefaultTableModel model = new DefaultTableModel(null, columns);
            //model.
            for(SanPhamBanTrongNgay sp: dsSanPham) {
                Object [] items = new Object [] {
                    stt,
                    sp.getTenSP(),
                    sp.getSl(),
                };              
                //int maLSP = sp.getMaLSP();
                model.addRow(items); 
                stt++;
            }         
            
            jtbDSMHDaXuat.setModel(model); 
            //jtbDSMHDaXuat.column
		int[] va = {5, 25, 15};
		int[] pt = new int[5];
		for (int l = 0; l < 3; l++) {
			pt[l] = jtbDSMHDaXuat.getWidth() * va[l] / 100;
			jtbDSMHDaXuat.getColumnModel().getColumn(l).setPreferredWidth(pt[l]);
                }
            
        }


	/**
	 * This method is called from within the constructor to initialize the
	 * form. WARNING: Do NOT modify this code. The content of this method is
	 * always regenerated by the Form Editor.
	 */
	@SuppressWarnings("unchecked")
       // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
       private void initComponents() {

              jPanel1 = new javax.swing.JPanel();
              jLabel5 = new javax.swing.JLabel();
              jPanel2 = new javax.swing.JPanel();
              jbtnLapBaoCao = new javax.swing.JButton();
              jlbTenNV = new javax.swing.JLabel();
              jlbTenNhanVien = new javax.swing.JLabel();
              jPanel3 = new javax.swing.JPanel();
              jScrollPane1 = new javax.swing.JScrollPane();
              jtbDSMHDaXuat = new javax.swing.JTable();
              jPanel5 = new javax.swing.JPanel();
              jLabel7 = new javax.swing.JLabel();
              jLabel4 = new javax.swing.JLabel();
              lbTSSPDX = new javax.swing.JLabel();
              lbTongSoLuong = new javax.swing.JLabel();
              jLabel1 = new javax.swing.JLabel();
              jlbTSLanXuatKho = new javax.swing.JLabel();

              setClosable(true);
              setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
              setIconifiable(true);
              setMaximizable(true);
              setResizable(true);

              jLabel5.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N
              jLabel5.setText("LẬP BÁO CÁO XUẤT KHO TRONG NGÀY");

              javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
              jPanel1.setLayout(jPanel1Layout);
              jPanel1Layout.setHorizontalGroup(
                     jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                     .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                            .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabel5)
                            .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
              );
              jPanel1Layout.setVerticalGroup(
                     jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                     .addGroup(jPanel1Layout.createSequentialGroup()
                            .addContainerGap()
                            .addComponent(jLabel5)
                            .addContainerGap())
              );

              jbtnLapBaoCao.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
              jbtnLapBaoCao.setText("Lập báo cáo");
              jbtnLapBaoCao.setToolTipText("gọi lập phiếu nhập kho");
              jbtnLapBaoCao.addActionListener(new java.awt.event.ActionListener() {
                     public void actionPerformed(java.awt.event.ActionEvent evt) {
                            jbtnLapBaoCaoActionPerformed(evt);
                     }
              });

              jlbTenNhanVien.setText("[Tên nhân viên]");

              javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
              jPanel2.setLayout(jPanel2Layout);
              jPanel2Layout.setHorizontalGroup(
                     jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                     .addGroup(jPanel2Layout.createSequentialGroup()
                            .addGap(52, 52, 52)
                            .addComponent(jlbTenNV)
                            .addGap(215, 215, 215)
                            .addComponent(jlbTenNhanVien)
                            .addGap(83, 83, 83)
                            .addComponent(jbtnLapBaoCao)
                            .addContainerGap(129, Short.MAX_VALUE))
              );
              jPanel2Layout.setVerticalGroup(
                     jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                     .addGroup(jPanel2Layout.createSequentialGroup()
                            .addContainerGap()
                            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                   .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                          .addComponent(jbtnLapBaoCao)
                                          .addComponent(jlbTenNV))
                                   .addComponent(jlbTenNhanVien))
                            .addContainerGap())
              );

              jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Danh sách mặt hàng đã bán:"));
              jPanel3.setName(""); // NOI18N
              jPanel3.setLayout(new javax.swing.BoxLayout(jPanel3, javax.swing.BoxLayout.LINE_AXIS));

              jtbDSMHDaXuat.setModel(new javax.swing.table.DefaultTableModel(
                     new Object [][] {

                     },
                     new String [] {
                            "STT", "Sản phẩm", "Số lượng"
                     }
              ));
              jScrollPane1.setViewportView(jtbDSMHDaXuat);

              jPanel3.add(jScrollPane1);

              jLabel7.setText("Tổng số lượng:");

              jLabel4.setText("Tổng sản phẩm đã xuất");

              lbTSSPDX.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
              lbTSSPDX.setText("0");

              lbTongSoLuong.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
              lbTongSoLuong.setText("0");

              jLabel1.setText("Tổng số lần xuất kho:");

              jlbTSLanXuatKho.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
              jlbTSLanXuatKho.setText("0");

              javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
              jPanel5.setLayout(jPanel5Layout);
              jPanel5Layout.setHorizontalGroup(
                     jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                     .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
                            .addGap(38, 38, 38)
                            .addComponent(jLabel4)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(lbTSSPDX)
                            .addGap(67, 67, 67)
                            .addComponent(jLabel7)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(lbTongSoLuong)
                            .addGap(89, 89, 89)
                            .addComponent(jLabel1)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(jlbTSLanXuatKho)
                            .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
              );
              jPanel5Layout.setVerticalGroup(
                     jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                     .addGroup(jPanel5Layout.createSequentialGroup()
                            .addContainerGap()
                            .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                   .addComponent(jLabel7)
                                   .addComponent(jLabel4)
                                   .addComponent(lbTSSPDX)
                                   .addComponent(lbTongSoLuong)
                                   .addComponent(jLabel1)
                                   .addComponent(jlbTSLanXuatKho))
                            .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
              );

              javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
              getContentPane().setLayout(layout);
              layout.setHorizontalGroup(
                     layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                     .addGroup(layout.createSequentialGroup()
                            .addGap(0, 0, 0)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                   .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                   .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                   .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                   .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
              );
              layout.setVerticalGroup(
                     layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                     .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                            .addGap(0, 0, 0)
                            .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(0, 0, 0)
                            .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(0, 0, 0)
                            .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, 338, Short.MAX_VALUE)
                            .addGap(0, 0, 0)
                            .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(0, 0, 0))
              );

              pack();
       }// </editor-fold>//GEN-END:initComponents

       private void jbtnLapBaoCaoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnLapBaoCaoActionPerformed
              // TODO add your handling code here:
              int mnv =Var.NV.getMaNV();

              loadSanPhamDaXuat(mnv);
              double sosanpham=CTPXuatKhoDao.TongSanPhamDaXuat(mnv);
              lbTSSPDX.setText(String.valueOf(sosanpham));
              int soluong=CTPXuatKhoDao.TongSoLuongDaXuatTrongNgay(mnv);
              lbTongSoLuong.setText(String.valueOf(soluong));
              int solanxuat=CTPXuatKhoDao.TongSoLanXuatKhoTrongNgay(mnv);
              jlbTSLanXuatKho.setText(String.valueOf(solanxuat));
       }//GEN-LAST:event_jbtnLapBaoCaoActionPerformed

	
       // Variables declaration - do not modify//GEN-BEGIN:variables
       private javax.swing.JLabel jLabel1;
       private javax.swing.JLabel jLabel4;
       private javax.swing.JLabel jLabel5;
       private javax.swing.JLabel jLabel7;
       private javax.swing.JPanel jPanel1;
       private javax.swing.JPanel jPanel2;
       private javax.swing.JPanel jPanel3;
       private javax.swing.JPanel jPanel5;
       private javax.swing.JScrollPane jScrollPane1;
       private javax.swing.JButton jbtnLapBaoCao;
       private javax.swing.JLabel jlbTSLanXuatKho;
       private javax.swing.JLabel jlbTenNV;
       private javax.swing.JLabel jlbTenNhanVien;
       private javax.swing.JTable jtbDSMHDaXuat;
       private javax.swing.JLabel lbTSSPDX;
       private javax.swing.JLabel lbTongSoLuong;
       // End of variables declaration//GEN-END:variables
}
